<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*
        1.注意换行之间的空格
     */
    let template1 = `first line
                     second line`;
    console.log(template1.length) // 43
    /*
        2.${}   所有插入的值都会使用toString()强制转型为字符串
     */
    let num1 = 3,
        num2 = 7,
        word = {toString: () => 'hello world'}
    console.log(`${num1}*${num2}=${num1 * num2},${word}`)

    /*
        3(new).模板字面量标签函数
     */
    let a = 1,
        b = 2;
    function sum(preStr,a,b,result) {
        console.log('---模板函数---')
        console.log('preStr',preStr)
        console.log('a',a)
        console.log('b',b)
        console.log('result',result)
        return result;
    }
    let result = sum`${a}+${b} = ${a+b}`
    console.log(result)

</script>
</body>
</html>